/**
 * Created by Administrator on 2018/6/26.
 */
/*下拉搜索*/
// $(function () {
//     $('#publishuser').searchableSelect();
// });

/*定位省市联动*/
$("#sheng").on("change", function () {
    var city = $("#sheng").val();
    getCity(city);
})
function getCity(city) {
    $.ajax({
        url: '/admin/message/city',
        data: {city: city},
        type: 'POST',
        dataType: 'json',//返回的数据类型
        success: function (data) {
            var cityArray = data.cityArray;
            $("#city").html("");
            var html = " <option value=''>全部</option>";
            $.each(cityArray, function (i, item) {
                html += "<option value='" + item.district_id + "'>" + item.district + "</option>";
            });
            $("#city").append(html);
        }
    })
}
/*发布省市联动*/
$("#publishsheng").on("change", function () {
    var city = $("#publishsheng").val();
    getpCity(city);
})
function getpCity(city) {
    $.ajax({
        url: '/admin/message/city',
        data: {city: city},
        type: 'POST',
        dataType: 'json',//返回的数据类型
        success: function (data) {
            var cityArray = data.cityArray;
            $("#publishcity").html("");
            var html = " <option value=''>全部</option>";
            $.each(cityArray, function (i, item) {
                html += "<option value='" + item.district_id + "'>" + item.district + "</option>";
            });
            $("#publishcity").append(html);
        }
    })
}
/*表单*/
$('#adtvmadd').click(function () {
    var data = new FormData($("#adtvminfo")[0]);
    $.ajax({
        url: '/admin/Message/articleAdd',
        type: 'POST',
        data: data,
        dataType: 'JSON',
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success: function (res) {
            if (res.code == 2000) {
                dshow(res.message);
                window.location.href = '/admin/Message/CommonIndex'
            } else {
                dshow(res.message);
            }
        }
    })
})




